<template>
	<view class="result-container">
		<image class="bg" src="../../static/result-bg.png" mode="widthFix"></image>
		<div class="content-box">
			<view class="into">
				<image src="../../static/success.png" class="success" mode="widthFix"></image>
				<view class="su-text">
					恭喜您！初审已经通过
				</view>
			</view>
			<view class="content2">
				<view class="row1">
					<view class="left">
						<view class="amount">
							{{data.amount||20000}}
						</view>
						<view class="label">
							预估额度
						</view>
					</view>
					<view class="right">
						<view class="qixian">
							3-36期
						</view>
						<view style="margin-top: 0.4em;" class="label">
							预估期限
						</view>
					</view>
				</view>
				<view class="row2">
					<view v-if="data.companyName" class="left">
						<view class="com-name">
							{{data.companyName}}
						</view>
						<view class="com-desc">
							{{data.speInfoName}}
						</view>
					</view>
					<view v-else class="left">
						<view class="com-name">
							正在匹配客户经理...... <br>将继续为您匹配客户经理直至成功
						</view>
					</view>
					
					<image v-if="data.companyPhone" class="right" src="../../static/call.png" mode="widthFix"></image>
				</view>
				<view v-if="data.companyUser" class="address">
					<image src="../../static/lo.png" mode="widthFix"></image>
					联系人：{{data.companyUser+' '+data.companyPhone}}
				</view>
				<image  style="width: 100%;margin-top: 100rpx;" src="../../static/step.png" mode="widthFix"></image>
			</view>
			<view class="btns">
				<image src="../../static/yet.png" mode="widthFix"></image>
				<MbuttomVue @click="clickProduct(headProducts,2)">领取更多额度</MbuttomVue>
			</view>
		</div>
	</view>
</template>



<script>
	import MbuttomVue from '../../components/Mbuttom.vue';
	export default {
		components:{
			MbuttomVue
		},
		data() {
			return {
				products: [],
				headProducts: {},
				productsfuchuang: [],
				bannerProducts: [],
				data:{}
	
			}
		},
		onLoad() {
				this.data = uni.getStorageSync('spePushResut')||{};
			if (uni.getStorageSync('authorize') == true) {
				uni.setStorageSync('authorize', false)
				// #ifdef H5
				window.location.href = uni.getStorageSync('authorizeUrl')
				// #endif
	
				return;
	
			}
	
			this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight
	
	
			this.getProductList(2)
			this.getProductList(3)
			this.getProductList(4)
			this.getProductList(6)
			
	
			//挂载成功后给pop事件绑定一个方法
			// 如果支持 popstate （一般移动端都支持）
		
	
		},
		onPullDownRefresh() {
	
			this.getProductList(2)
			this.getProductList(3)
			this.getProductList(4)
			this.getProductList(6)
		},
		onReady() {
	
		
	
		},
		methods: {
			//24小时倒计时
			
	
			open() {
				this.$refs.popup.open('center')
				uni.setStorageSync('homewindow', false)
	
			},
			close() {
				this.$refs.popup.close()
			},
			async getProductList(e) {
				const res = await this.$myRequest({
					url: 'api/product/list',
					method: 'post',
					data: {
						'sceneId': e
					}
				});
				//头部产品
				if (e == 2) {
					var headProductsList = res.dataList
					var num = Math.floor(Math.random() * headProductsList.length)
					// console.log(num)
					Object.assign(this.headProducts, headProductsList[num])
	
					if (headProductsList.length > 0) {
						// this.clickProduct(this.headProducts, 2)
					}
	
	
				}
				//列表产品
				else if (e == 3) {
					this.products = res.dataList
					// console.log(this.products)
	
	
				} else if (e == 4) {
					this.productsfuchuang = res.dataList
				} else if (e == 6) {
					this.bannerProducts = res.dataList
				}
				uni.stopPullDownRefresh();
	
			},
			async clickProduct(item, dataExt) {
				// console.log(item)
	
				await this.saveClick(item.productId, dataExt)
				if (item.unionFlag == 1) {
					this.getldUrl(item.productId)
				} else {
					// #ifdef H5
					window.location.href = item.detailUrl
					// #endif
				}
	
	
			},
			async saveClick(s, dataExt) {
				// console.log(s)
				const res = await this.$myRequest({
					url: 'api/sys/count',
					method: 'post',
					data: {
						'dataId': s,
						'operType': '2',
						'dataExt': dataExt
					}
				});
			},
			async getldUrl(s) {
				const res = await this.$myRequest({
					url: 'api/product/unionInfo',
					method: 'post',
					data: {
						'productId': s,
	
					}
				});
				// #ifdef H5
				window.location.href = res.productUrl
				// #endif
			},
			
	
	
		}
	}
</script>

<style lang="scss">
.result-container{
	.bg{
		width: 100%;
		position: absolute;
		z-index: -1;
	}
	.content-box{
		width: 78vw;
		margin: 0 auto;
		padding-top: 15vw;
		.into{
			text-align: center;
		}
		.success{
			width: 156rpx;
		}
		.su-text{
			color: #333333;
			font-size: 40rpx;
			font-weight: bold;
			margin-top: 15rpx;
		}
	}
	.content2{
		margin-top: 9vw;
		.row1{
			display: flex;
			justify-content: space-around;
			align-items: flex-end;
			.label{
				color: #848484;
				font-size:28rpx;
			}
			.amount{
				color: #FF5044;
				font-size: 72rpx;
				font-weight: bold;
				&::before{
					content: '¥';
					font-weight: normal;
					font-size: 0.6em;
					margin-right: 4rpx;
				}
			}
			.qixian{
				color: #333333;
				font-size:40rpx;
				font-weight: bold;
				
			}
		}
		.row2{
			display: flex;
			align-items: center;
			justify-content: space-between;
			margin-top: 80rpx;
			.com-name{
				color: #333333;
				font-size: 32rpx;
				font-weight: bold;
			}
			.com-desc{
				color: #848484;
				font-size:28rpx;
			}
			.right{
				width: 72rpx;
				
			}
		}
		.address{
			color: #696969;
			font-size: 24rpx;
			display: flex;
			align-items: center;
			margin-top: 50rpx;
			image{
				width: 32rpx;
				margin-right: 8rpx;
			}
		}
		
	}
	.btns{
		position: relative;
		margin-top: 80rpx;
		image{
			width: 260rpx;
			position: absolute;
			right: 5%;
			top:-30%;
		}
	}
}
</style>
